<!doctype html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
        body,
        ul,
        ol,
        li,
        img {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        #box {
            width: 490px;
            height: 170px;
            padding: 5px;
            position: relative;
            border: 1px solid #ccc;
            margin: 100px auto 0;
            overflow: hidden;
        }

        .ad {
            width: 490px;
            height: 170px;
            overflow: hidden;
            position: relative;
        }

        #box img {
            width: 490px;
        }

        .ad ol {
            position: absolute;
            right: 10px;
            bottom: 10px;
        }

        .ad ol li {
            width: 20px;
            height: 20px;
            line-height: 20px;
            border: 1px solid #ccc;
            text-align: center;
            background: #fff;
            float: left;
            margin-right: 10px;
            cursor: pointer;
            _display: inline;
        }

        .ad ol li.current {
            background: yellow;
        }

        .ad ul li {
            float: left;
        }

        .ad ul {
            position: absolute;
            top: 0;
            width: 2940px;
        }

        .ad ul li.current {
            display: block;
        }

        #arr {
            display: none;
        }

        #arr span {
            width: 40px;
            height: 40px;
            position: absolute;
            left: 5px;
            top: 50%;
            margin-top: -20px;
            background: #000;
            cursor: pointer;
            line-height: 40px;
            text-align: center;
            font-weight: bold;
            font-family: '黑体';
            font-size: 30px;
            color: #fff;
            opacity: 0.3;
            border: 1px solid #fff;
        }

        #arr #right {
            right: 5px;
            left: auto;
        }

        div {
            background-color: red;
            filter: alpha(opacity=50);
        }
    </style>

    <script src="./../js/aniamte.js"></script>
</head>

<body>
    <div id="box" class="all">
        <div class="ad">
            <ul id="imgs">
                <li><img src="images/1.jpg" /></li>
                <li><img src="images/2.jpg" /></li>
                <li><img src="images/3.jpg" /></li>
                <li><img src="images/4.jpg" /></li>
                <li><img src="images/5.jpg" /></li>
            </ul>
        </div>
        <div id="arr">
            <span id="left"> &lt; </span>
            <span id="right"> &gt;
            </span>
        </div>
    </div>
</body>

</html>
<script>

    class Swiper {
        constructor(ele) {
            //属性
            this.el = document.querySelector(ele);
            this.oUl = this.el.children[0].children[0];
            this.oArr = this.el.children[1];

            this.imgIndex = 0;
            this.mouseHandler();
        }
        //行为
        mouseHandler() {
            //鼠标进入显示
            this.el.addEventListener("mouseenter", () => {
                this.oArr.style.display = "block";
            })
            //鼠标离离开
            var self = this;
            this.el.addEventListener("mouseleave", function () {
                self.oArr.style.display = "none";
            })

            //left
            this.oArr.children[0].onclick = function () {
                self.imgIndex++;
                if (self.imgIndex > 4) {
                    self.imgIndex = 4;
                }
                utils.animate(self.oUl, { left: self.imgIndex * -490 })
            }
            //right
            this.oArr.children[1].onclick = function () {
                self.imgIndex--;
                if (self.imgIndex < 0) {
                    self.imgIndex = 0;
                }

                utils.animate(self.oUl, { left: self.imgIndex * -490 })
            }
        }
    }

    new Swiper("#box");


</script>